package com.example.xiaoxueqixiangmu;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

public class ViewPageActivity extends AppCompatActivity {
    private ViewPager myViewPager; // 要使用的ViewPager
    private View pageTicket, pageOrder, pageMine; // ViewPager包含的页面
    private List<View> pageList; // ViewPager包含的页面列表，一般给adapter传的是一个list

    private MyPagerAdapter myPagerAdapter; // 适配器

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view_page);

            myViewPager = findViewById(R.id.viewpager);
            pageList = new ArrayList<>();

            LayoutInflater inflater = getLayoutInflater();
            pageTicket = inflater.inflate(R.layout.activity_ticket, null);
            pageOrder = inflater.inflate(R.layout.activity_order, null);
            pageMine= inflater.inflate(R.layout.activity_mine, null);

            pageList.add(pageTicket);
            pageList.add(pageOrder);
            pageList.add(pageMine);



            myPagerAdapter = new MyPagerAdapter(pageList);
            myViewPager.setAdapter(myPagerAdapter);

        }

    }
